package com.neu.mapper;


import com.neu.pojo.Clazz;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.GetMapping;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

@Mapper
public interface ClazzMapper {

    //@Select("select c.*,e.name as masterName from clazz c left join emp e on c.master_id=e.id order by c.update_time desc;")
    public List<Clazz> list(String name, LocalDate begin, LocalDate end);

    @Insert("insert into clazz(id,name,room,begin_date,end_date,master_id,subject,create_time,update_time) " +
            "values (null,#{name},#{room},#{beginDate},#{endDate},#{masterId},#{subject},#{createTime},#{updateTime})")
    void insert(Clazz clazz);

    @Delete("delete from clazz where id=#{id}")
    void deleteById(Integer id);

    @Select("select * from clazz where id=#{id}")
    Clazz getById(Integer id);


    void update(Clazz clazz);

    @Select("select * from clazz")
    List<Clazz> findAll();


    List<Map<String, Object>> countClazzData();
}
